import sys
sys.path.append("../../")

from model.StockBaseInfo import *
from model.CommonDb import *
import datetime

class TalkController:
    def __init__(self,args):
        self.args = args
        self.service = StockBaseInfo()
        self.today = datetime.datetime.now().strftime("%Y-%m-%d")
    def run(self):
        if self.args["func"] == "addTalkDay":
            return self.addTalkDay(self.args)
        elif self.args["func"] == "getDaPan":
            return self.getDaPan()

    """
    添加总体评论
    """
    def addTalkDay(self,args):
        db = CommonDb("talk_day", "sto")
        info = {
            "code": args["code"],
            "count_day": self.today,
            "type": args["code"],
            "content": args["content"]
        }
        db.add(info)

    def getDaPan(self):
        db = CommonDb("talk_day", "sto")
        rs = db.selectRowDataByWhere("content","code='sh000001' order by count_day limit 1")
        return rs[0]["content"]
